<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据类型</title>
</head>

<body>
    <script>
        /* var arr = [1, 2, 3, 4]
        var obj = {
            name: "jack",
            age: 18,
        };
        var fun = function (a, b) {
            console.log(a + b);
        };
        fun(1, 2);  */

        /* var str = "123";
        num = 999;
        flag = true;
        ud = undefined;
        nu = null;
        console.log(String(num), String(flag), String(ud), String(nu));
        //全部变成对应的字符串,"999"，"true","undefined","null"

        console.log(num.toString());
        console.log(true.toString());
        // console.log(ud.toString());报错
        // console.log(null.toString());报错 */
        /*
                var num = 10;
                console.log(num.toString(2));
                //二进制，结果为1010
                console.log(num.toString(8));
                //八进制
                console.log(num.toString(16));
                //十六进制 */

        /* var str = "123";
        flag = true;
        ud = undefined;
        nu = null;
        console.log(Number(str));//123
        console.log(Number(flag));//1
        console.log(Number(!flag));//0
        console.log(Number(ud));//NaN
        console.log(Number(nu));//0

        var d = new Date();
        console.log(d);
        //打印日期
        console.log(Number(d));
        //将日期时间转换成数字(时间戳) */

        /*  var str = "frontEnd";
        var numstr = "123front";
        var fl = "3.14";
        console.log(parseInt(str), parseInt(numstr), parseInt(fl));
         //NaN 123 3
        console.log(parseFloat(str), parseFloat(numstr), parseFloat(fl));
         // NaN 123 3.14
        console.log(parseInt("200", 10));//200
         console.log(parseInt("11", 2));//以二进制来解析11得到结果是3 */

        /* var num = 123456.789;
        console.log(num.toFixed(0), num.toFixed(2), num.toFixed(5)); */

        var str = "";
        var strl = "";
        var num = 0;
        var numl = 1;
        var nu = null;
        var ud = undefined;
        var arr = [];
        var obj = {};
        console.log(Boolean(str));//false
        console.log(Boolean(strl));//false
        console.log(Boolean(num));//false
        console.log(Boolean(numl));//true
        console.log(Boolean(nu));//false
        console.log(Boolean(ud));//false
        console.log(Boolean(arr));//true
        console.log(Boolean(obj));//true
    </script>
</body>

</html>